package main

import (
	"encoding/xml"
	"fmt"
	"io/ioutil"
)
type XMLData struct {
	//XMLName xml.Name `xml:"note"`
	//Version string `xml:"version,attr"`
	ServerName string `xml:"servername" json:"serverName"`
	Email string `xml:"email" json:"email"`
}

type Server struct {
	XMLName xml.Name `xml:"servers" json:"xmlName"`
	Version string `xml:"version,attr" json:"version"`
	//Encoding string `xml:"encoding,attr" json:"encoding"`
	Servers []XMLData `xml:"server" json:"servers"`
}

func main() {
	var server Server
	bytes, err:= ioutil.ReadFile("study.com\\base\\xml数据\\xml.xml")
	if err!=nil{
		fmt.Println("ReadFile error:",err)
		return
	}
	err = xml.Unmarshal(bytes, &server)
	if err!=nil{
		fmt.Println("Unmarshal error:",err)
		return
	}
	fmt.Println(server)
}


